import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import News from '../views/News.vue'
import Life from '../views/Life.vue'
import InterNews from '../views/news/InterNews.vue'
import HomeNews from '../views/news/HomeNews.vue'
Vue.use(VueRouter)

const routes = [
  {
    path: '/home',
    name: 'Home',
    component: Home
  },
  {
	path: '/news',
	name: 'News',
	component: News,
	children:[
		{
			path:'internews',
			name:'InterNews',
			// component:InterNews
			components:{
				default:InterNews
			}
		},
		{
			path:'homenews',
			name:'HomeNews',
			// component:HomeNews
			components:{
				home:HomeNews
			}
		},
	]
  },
  {
	path: '/life',
	// path: '/life/:mycity',
	name: 'Life',
	component: Life
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  },
  {
	  path:'/login',
	  name:'login',
	  // redirect:'/register',
	  component:()=>import('../views/user/login.vue')
  },
  {
  	  path:'/register',
  	  name:'register',
  	  component:()=>import('../views/user/register.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
const Auth={
	isLogin(){
		return false
	}
}
/* router.beforeEach((to,from,next)=>{
	
	if(to.name != 'login'){
		console.log('要去验证')
		if(Auth.isLogin()){
			next()
		}
		else{
			next('/login')
		}
	}
	else{
		next()
	}
	
}) */

export default router
